package org.example.handle;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.example.domin.School;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Aspect 表示这是一个切面类
 */
@Aspect
public class MyAspect {
    /**
     * 切面的环绕通知
     *   属性:value 切入点表达式
     *   位置在方法上定义
     *
     *   返回值：Object,
     */
    @Around("execution(* org.example.service.SchoolService.get(..))")
    public School myAround(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("执行了环绕通知的myAround方法");

        //执行方法本身
        Object methodReturn=null;
        methodReturn= pjp.proceed();
        System.out.println("方法本身的返回值："+methodReturn);

        School school=new School();
        school.setName("123");
        school.setAddress("000");
        return school;
    }
}
